<?php
namespace app\common\model;
use app\admin\model\Admin;
use think\Model;
use think\model\concern\SoftDelete;

class Customer extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;

    /**
     * 关联用户
     * @return \think\model\relation\BelongsTo
     */
    public function from()
    {
        return $this->belongsTo(DictData::class,'from_id','id')->bind(['from_name'=>'name']);
    }

    /**
     * 关联行业
     * @return \think\model\relation\BelongsTo
     */
    public function trade()
    {
        return $this->belongsTo(DictData::class,'trade_id','id')->bind(['trade_name'=>'name']);
    }

    /**
     * 关联用户
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(Admin::class,'user_id','id')->bind(['user_name'=>'name']);
    }

    /**
     * 关联用户
     * @return \think\model\relation\BelongsTo
     */
    public function kefu()
    {
        return $this->belongsTo(Admin::class,'kefu_id','id')->bind(['kefu_name'=>'name']);
    }

    /**
     * 读取状态
     * @param $value
     * @param $data
     * @return mixed|string
     */
    public function getStatusNameAttr($value,$data)
    {
        $name = get_param('Status',$data['status']);
        return $name;
    }



}